/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2011-11-1
/// Purpose: 		数据访问上下文设置元素定义类文件
/// ****************************************************************************
/// Modify By		Date			Remark
/// ****************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Collections.Specialized;

namespace RB.DataAccess.Configuration
{
    /// <summary>
    /// 数据访问上下文设置元素定义类
    /// </summary>
    public class DataContextConfigElement : ConfigurationElement
    {
        [ConfigurationPropertyAttribute("name", DefaultValue = "defaultContext")]
        public string Name 
        {
            get
            {
                return (string)this["name"];
            }
            set
            {
                this["name"] = value;
            }
        }

        [ConfigurationPropertyAttribute("type", DefaultValue = "RB.DataAccess.SqlServer")]
        public string Type
        {
            get
            {
                return (string)this["type"];
            }
            set
            {
                this["type"] = value;
            }
        }

        [ConfigurationPropertyAttribute("connectionStringName", DefaultValue = "connectionString")]
        public string ConnectionStringName
        {
            get
            {
                return (string)this["connectionStringName"];
            }
            set
            {
                this["connectionStringName"] = value;
            }
        }

        private NameValueCollection _parameters = null;

        public NameValueCollection Parameters {
            get
            {
                if (_parameters == null)
                {
                    _parameters = new NameValueCollection();
                    foreach (PropertyInformation info in this.ElementInformation.Properties)
                    {
                        _parameters.Add(info.Name, Convert.ToString(info.Value));
                    }
                }
                return _parameters;
            }
        }
    }
}
